#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    vector<string> ans;
    string path = "";
    string hash[10] = { "", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
    vector<string> letterCombinations(string digits) {
        if (digits.size() == 0) return ans;
        dfs(digits, 0);
        return ans;
    }
    void dfs(string& digits, int pos) {
        if (pos == digits.size()) {
            ans.push_back(path);
            return;
        }
        for (int i = 0; i < hash[digits[pos] - '0'].size(); i++) {
            path.push_back(hash[digits[pos] - '0'][i]);
            dfs(digits, pos + 1);
            path.pop_back();
        }
    }
};